<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of DeniedEvents
 *
 * @author Schorr
 */
class Fkb_Validate_DeniedEvents extends Zend_Validate_Identical{
    
    const EVENT_STATUS_INVALID = "eventStatusInvalid";
    
    protected $_messageTemplates = array(
	self::EVENT_STATUS_INVALID => "'%value%' kann für den Zeitraum nicht gewählt werden");
    
     public function isValid($value, $context = null){
	
	$this->_setValue((string) $value);
        if (($context !== null) && isset($context) && array_key_exists($this->getToken(), $context)) {
            $token = $context[$this->getToken()];
        } else {
            $token = $this->getToken();
        }

	//var_dump($context);
	//die();
	$m = new Model_Event();
	$event = $m->find($context['event_id']);

	if(!($m->exceedsMaxTotalParallelCaresits($event))){
	    return true;
	}
	else{
	    $this->_error(self::EVENT_STATUS_INVALID);
	    return false;
	}
     }
}

?>
